---
title: Health Bar
description: Displays an 8-bit health bar component.
---

import HealthBar from "@/components/ui/8bit/health-bar";
import CopyCommandButton from "@/components/copy-command-button";
import InstallationCommands from "@/components/installation-commands";
import ComponentPreview from "@/components/component-preview";

<div className="flex flex-col md:flex-row items-center justify-end gap-2 mb-2">
  <CopyCommandButton
    copyCommand="pnpm dlx shadcn@latest add @8bitcn/health-bar"
    command="pnpm dlx shadcn@latest add @8bitcn/health-bar"
  />
</div>

<ComponentPreview title="8-bit Health Bar component" name="health-bar">
  <div className="md:min-w-[300px] min-w-[200px] flex flex-col gap-8">
    <div>
      <p className="text-sm text-muted-foreground mb-2">
        Default health bar
      </p>
      <div className="flex justify-between text-sm mb-2 retro">
        <span>Health</span>
        <span>75%</span>
      </div>
      <HealthBar value={75} />
    </div>
    <div>
      <p className="text-sm text-muted-foreground mb-2">
        Retro health bar
      </p>
      <div className="flex justify-between text-sm mb-2 retro">
        <span>Health</span>
        <span>45%</span>
      </div>
      <HealthBar value={45} variant="retro" />
    </div>
  </div>
</ComponentPreview>

## Installation

---

<InstallationCommands packageName="health-bar" />

## Usage

---

```tsx
import { HealthBar } from "@/components/ui/8bit/health-bar"
```

```tsx
<HealthBar value={75} />
```

